import unittest
import barker
import barkerpair


class TestBarker(unittest.TestCase):
    def test_get_autocorrelation(self):
        autocorrelation = barker.get_autocorrelation([1, -1])
        self.assertEqual(autocorrelation, [2, -1])

    def test_is_barker_code(self):
        autocorrelation = [2, 1]
        self.assertTrue(barker.is_barker_code(autocorrelation))


class TestBarkerPair(unittest.TestCase):
    def test_get_autocorrelation(self):
        autocorrelation = barkerpair.get_autocorrelation([[1, -1], [1, -1]])
        self.assertEqual(autocorrelation, [2, -1])

    def test_is_barker_pair(self):
        autocorrelation = [2, 1]
        self.assertTrue(barkerpair.is_barker_pair(autocorrelation))

    def test_get_mth_sequence(self):
        n = 3
        for m in range(1,2**n+1):
            print(barkerpair.get_mth_sequence(n,m))

if __name__ == '__main__':
    unittest.main()
